package com.ruoyi.odorservice.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.odorservice.entity.SampleDetail;
import com.ruoyi.odorservice.entity.model.SampleDetailWithMaterial;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SampleDetailMapper extends BaseMapper<SampleDetail> {

    @Select("SELECT o.*, m.material_type, m.material_name_en, m.odor_characteristics, m.main_application " +
            "FROM (SELECT * FROM odor_sample_detail WHERE sample_id IN (${sampleIds})) o " +
            "LEFT JOIN odor_material m ON o.material_name = m.material_name")
    List<SampleDetailWithMaterial> selectSampleDetailWithMaterial(@Param("sampleIds") String sampleIds);
}
